package fulbiNet.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import fulbiNet.execpcion.DAOExcepcion;
import fulbiNet.modelo.Persona;
import fulbiNet.negocio.AdministrarPersonaNegocio;

/**
 * Servlet implementation class RegistrarPersonaServlet
 */
@WebServlet("/RegistrarPersonaServlet")
public class RegistrarPersonaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegistrarPersonaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		

		String Nombres=request.getParameter("Nombres");
		String Paterno=request.getParameter("Paterno");
		String Materno=request.getParameter("Materno");
		String Sexo=request.getParameter("Sexo");
		String TipoDoc=request.getParameter("TipoDoc");
		String NroDoc=request.getParameter("NroDoc");
		String Correo=request.getParameter("Correo");
	
		String Contrasena=request.getParameter("Contrasena");
		String FechaNac=request.getParameter("FechaNac");
		String Celular=request.getParameter("Celular");
		
		Persona vo = new Persona();
		
		vo.setNombres(Nombres);
		vo.setPaterno(Paterno);
		vo.setMaterno(Materno);
		vo.setSexo(Sexo);
		vo.setTipodocumento(TipoDoc);
		vo.setNrodocumento(NroDoc);
		
		vo.setEmail(Correo);
		vo.setContrasena(Contrasena);
		vo.getFnacimiento2();
		vo.setCelular(Celular) ;
		
		AdministrarPersonaNegocio neg = new AdministrarPersonaNegocio();	
try
{
	neg.insertarPersona(vo);
	int idPersona = neg.obteneridPersona() ;
		
	
	vo.setCodigo(idPersona);
	neg.insertarPersona(vo);
	response.sendRedirect(request.getContextPath() + "/Fulbinet.jsp/RegistrarPersona.jsp");	
		
} catch (DAOExcepcion e){


e.printStackTrace();

	}
}
}